package com.fshuqing.learing.spring.applicationcontext;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * BeanPostProcess会在每个bean初始化的时候调用一次，两个方法都不能return null
 * @author fshuqing
 */
@Component
public class EchoBeanPostProcessor implements BeanPostProcessor {
    /**
     * bean属性装配完成之后
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("===postProcessBeforeInitialization===" + bean.getClass());
        return bean;
    }

    /**
     * bean的init方法执行之后执行的
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("===postProcessAfterInitialization===");
        return bean;
    }
}
